<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    .animate{
      width: 100px;
      height: 100px;
      background: #000;
      animation: box-animate 2s infinite; /*重点是infinite，一直播放动画*/
    }
    @keyframes box-animate{
      0%{
        opacity:1
      }
      50%{
        opacity: 0.5
      }
      100%{
        opacity: 1;
      }
    }
  </style>
</head>
<body>
  <div class="animate"></div>
</body>
</html>